<%@ page contentType="text/html;charset=UTF-8" %> 
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>


<h3>Uczniowie</h3>

<form:form commandName="student">
<table>

	<tr>
	<td colspan="2">
	
	<div style="color: green">${dodano}</div>

	
	</td>
	</tr>
	<tr>
	<td colspan="2">
	
	<form:errors path="userLogin" cssClass="error_box" />

	
	</td>
	</tr>
	<tr>
		<td><form:label path="userLogin">Login:</form:label></td>
		<td><form:input path="userLogin" /></td>
	</tr>
	<tr>
	<td colspan="2">
	
	<form:errors path="userPassword" cssClass="error_box" />

	
	</td>
	</tr>
	<tr>
		<td><form:label path="userPassword">Hasło:</form:label></td>
		<td><form:password path="userPassword" /></td>
	</tr>
	<tr>
	<td colspan="2">
	
	<form:errors path="repeatPassword" cssClass="error_box" />

	
	</td>
	</tr>
	<tr>
		<td><form:label path="repeatPassword">Powtórz hasło:</form:label></td>
		<td><form:password path="repeatPassword" /></td>
	</tr>
	<tr>
	<td colspan="2" style="padding-top: 20px">
	
	<form:errors path="firstName" cssClass="error_box" />

	
	</td>
	</tr>
	<tr>
		<td><form:label path="firstName">Imię:</form:label></td>
		<td><form:input path="firstName" /></td>
	</tr>
	<tr>
	<td colspan="2">
	
	<form:errors path="lastName" cssClass="error_box" />

	
	</td>
	</tr>
	<tr>
		<td><form:label path="lastName">Nazwisko:</form:label></td>
		<td><form:input path="lastName" /></td>
	</tr>
	<tr>
	<td colspan="2">
	
	<form:errors path="classMember" cssClass="error_box" />

	
	</td>
	</tr>
	<tr>
		<td><form:label path="classMember">Klasa:</form:label></td>
		<td><form:select path="classMember">
				<form:option value="" label="Wybierz klasę" />
				<form:options items="${listOfClasses}" />
			</form:select>
		</td>
	</tr>
</table>
<input type="submit" value="Dodaj ucznia" />
</form:form><br /><br />
<c:if test="${studentsList.size() != 0}">
<table class="content_table">
	<tr>
		<th>Nazwisko</th>
		<th>Imię</th>
		<th>Login</th>
		<th>Klasa</th>
		<th>Opcje</th>
	</tr>
<c:forEach items="${studentsList}" var="student">

<tr>
		<td>
		${student.lastName}
		
		</td>
		<td>${student.firstName}</td>
		<td style="text-align: right">${student.userLogin}</td>
		<td style="text-align: center">
			<c:forEach items="${student.classeses}" var="classItem">
				<a href="<c:url value="/admin/class" />?id=${classItem.classId}">${classItem.className}</a>&nbsp;
			</c:forEach>
		</td>
		<td>
		<a href="<c:url value="/admin/student/edit" />?id=${student.userId}" >
		<img src="<c:url value="/resources/edit.gif" />" /> 
		</a>
		
		<a href="<c:url value="/admin/student/delete" />?id=${student.userId}" >
		<img src="<c:url value="/resources/delete.gif" />" />
		
		</td>
	</tr>

</c:forEach>
</table>
<br />

<!--  PAGE MENU -->
<c:if test="${students.getPage() != 0}">
<a href="<c:url value="/admin/students" />?page=${students.getPage()-1}" />
</c:if>
<
<c:if test="${students.getPage() != 0}">
</a>
</c:if>
<c:forEach begin="0" end="${students.getPageCount()-1}" var="page">
<c:if test="${students.getPage() != page}">
<a href="<c:url value="/admin/students" />?page=${page}" />
</c:if>
${page+1}
<c:if test="${students.getPage() != page}">
</a>
</c:if> 
</c:forEach>
<c:if test="${students.getPage() != students.getPageCount()-1}">
<a href="<c:url value="/admin/students" />?page=${students.getPage()+1}" />
</c:if>
>
<c:if test="${students.getPage() != 0}">
</a>
</c:if>
<!--  PAGE MENU KONIEC -->
</c:if>